package io.renren.sf.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.annotation.SysLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.sf.entity.MacAddressEntity;
import io.renren.sf.service.MacAddressService;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author cyl_txw
 * @email cyl_txw@gmail.com
 * @date 2021-03-18 15:41:54
 */
@RestController
@RequestMapping("sf/macaddress")
public class MacAddressController {
    @Autowired
    private MacAddressService macAddressService;

    /**
     * 信息
     */
    @GetMapping("/info/{macId}")
    //@RequiresPermissions("sf:macaddress:info")
    public R info(@PathVariable("macId") Long macId){
		MacAddressEntity macAddress = macAddressService.getById(macId);

        return R.ok().put("macAddress", macAddress);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("sf:macaddress:save")
    public R save(@RequestBody MacAddressEntity macAddress){
		macAddressService.save(macAddress);

        return R.ok();
    }

    /**
     * 修改
     */
    @SysLog("开关MAC状态")
    @PostMapping("/update")
    //@RequiresPermissions("sf:macaddress:update")
    public R update(@RequestBody MacAddressEntity macAddress){
		macAddressService.updateById(macAddress);

        return R.ok();
    }

    /**
     * 删除
     */
    @PostMapping("/delete")
    //@RequiresPermissions("sf:macaddress:delete")
    public R delete(@RequestBody Long[] macIds){
		macAddressService.removeByIds(Arrays.asList(macIds));

        return R.ok();
    }

}
